import React, { Component,useState } from 'react';
import PubSub from 'pubsub-js'
import Typeadd from '../../../../gonggong/typeadd'
import { Button ,Modal } from 'antd';
import 'antd/dist/antd.css'

const App = (e) => {
    const [isModalVisible, setIsModalVisible] = useState(false);
  
    const showModal = () => {
      setIsModalVisible(true);
    };
  
    const handleOk = () => {
      e.gengxin()
      setIsModalVisible(false);
    };
  
    const handleCancel = () => {
      PubSub.publish('arguigu',{display:"none"})
      e.gengxin()
      setIsModalVisible(false);
    };
  
    return (
      <>
        <Button type="primary" onClick={showModal}>
          {e.name}
        </Button>
        <Modal  width="648px" title="添加一级分类" visible={isModalVisible} onOk={handleOk} onCancel={handleCancel} closable footer={null}>
        <Typeadd type={e.type}  gengxin={e.gengxin} add={e.add}/>
        </Modal>
      </>
    );
  };
class index extends Component {
    render() {
        const {record ,name,gengxin,add,type}=this.props
        return (
            <div>
                <App type={type} add={add} gengxin={gengxin} record={record} name={name}/>
            </div>
        );
    }
}

export default index;